package com.easy.mybatis.multidatasource.controller;

import com.easy.mybatis.multidatasource.entity.User;
import com.easy.mybatis.multidatasource.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/mybatis")
public class Controller {

    @Autowired
    private IUserService iUserService;

    @GetMapping("/add")
    public String addMybatis(){
        User user = new User();
        user.setId(6L);
        user.setAge(27);
        user.setEmail("18202417075@163.com");
        user.setName("kepler");
        iUserService.insert(user);
        return "ok";
    }

    @GetMapping("/get")
    public String getMybatis(){
        User user = iUserService.selectById(6);
        return user.getName();
    }
}
